import json
from moviepy.editor import *
clip = VideoFileClip("E:\\movie\\20231230-赛琳娜的黄金\\origin.mp4")

from src.utils.file_utils import write_file,read_file
input_dict = read_file(r'E:\movie\20231230-赛琳娜的黄金\srt\rewrite.txt1', out_type='json')

out_put_temp = ""
text_set = set()
for i in input_dict:
    if i['reshort'].strip()!= "" and  i['reshort'].strip() in text_set:
        print("error")
        print(i['reshort'].strip())
    text_set.add(i['reshort'].strip())
    if i['reshort'].strip():
        if i['reshort'].strip().endswith("。") :
            out_put_temp += i['reshort'].strip()
        else:
            out_put_temp += i['reshort'].strip() + "。"
print(out_put_temp)
    # parts = i['rewrite'].split("。")


#
# if out_put_temp:
#     print(out_put_temp)





# input_dict = read_file(r'E:\movie\20231204-弹一下脑门对分手造成的影响\temp\second_convert_file.txt', out_type='json')
# for index, i in enumerate(input_dict):
#     j = json.loads(i)
#     print("index:"+str(index))
#     print(j["heap_index"])
#     print(j['max_relative_heap_index'])
#     print(j["relative_heap_index"])
#     print("")


# write_file(r'E:\movie\20231012-魔女1\srt\rewrite.txt1', input_dict, input_type='json')

# input_dict = read_file(r'E:\movie\20231012-魔女1\temp\second_convert_file.txt', out_type='json')
# for index,item in enumerate(input_dict):
#     print(item)


# from src.utils.matrix_utils import consine_similarity
#
# import numpy as np
#
# a = np.arange(50).reshape((1,50))
# b =  np.arange(1000).reshape((20,50))
#
# print(b[0:1,0:2])
# print(np.sum(b[0:1,0:2]))
#
# print(consine_similarity(a,b))



# import numpy as np
# # from sklearn.metrics.pairwise import cosine_similarity
# # vec1 = np.arange(0,500)
# # vec2 = np.arange(0,500)
# #
# # cos_sim = cosine_similarity(vec1.reshape(20, -1), vec2.reshape(20, -1))
# # print(cos_sim)
#
#
# import torch
# import torch.nn.functional as F
#
# vec1 = torch.FloatTensor(np.arange(0,500).reshape((20,-1)))
# vec2 = torch.FloatTensor(np.arange(0,500).reshape((10,-1)))
#
# cos_sim = F.cosine_similarity(vec1, vec2)
# print(cos_sim)